package com.SouthernWall_404.AgeRight.Common.Event;

import com.SouthernWall_404.AgeRight.Common.API.Capability.Locks;
import com.SouthernWall_404.AgeRight.Common.API.Capability.Provider.LocksProvider;
import com.SouthernWall_404.AgeRight.Common.API.Capability.Provider.MissionsProvider;
import com.SouthernWall_404.AgeRight.Common.AgeRight;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.chunk.LevelChunk;
import net.minecraftforge.event.AttachCapabilitiesEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;

public class AttachCapabilityEvent {

    @SubscribeEvent
    public static void onAttachCapabilityEvent(AttachCapabilitiesEvent event)
    {
         if(event.getObject()instanceof LevelChunk levelChunk)
         {
             Level level=levelChunk.getLevel();
             event.addCapability(
                         new ResourceLocation(AgeRight.MODID, "locks"),
                         new LocksProvider()
                 );
         }
         if(event.getObject() instanceof Player player)
         {
             event.addCapability(
                     new ResourceLocation(AgeRight.MODID,"missions"),
                     new MissionsProvider()
             );
         }
    }
}
